//
//  UIButton+Extension.swift
//  CZWeibo
//
//  Created by 周振兰 on 16/5/21.
//  Copyright © 2016年 周振兰. All rights reserved.
//

import UIKit
extension UIButton {
    convenience init(bkgImageName: String,imageName: String,title: String,titleColor: UIColor = UIColor.lightGrayColor(),fontSize: CGFloat = 12)
    {
        // 先调用当前类的指定或便利构造函数创建对象,创建完对象后给对象设置参数
        self.init(type:UIButtonType.Custom)
        //设置
        self.setBackgroundImage(UIImage(named: bkgImageName), forState: UIControlState.Normal)
        self.setBackgroundImage(UIImage(named:" \(bkgImageName)_highlighted"), forState: UIControlState.Highlighted)
        self.setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        self.setTitle(title, forState: UIControlState.Normal)
        self.setTitleColor(titleColor, forState: UIControlState.Normal)
        self.titleLabel?.font = UIFont.systemFontOfSize(fontSize)
    }
 
}
